{extend name="layout/layout" /}
<!--请在下方写此页面body相关内容-->
{block name="container"}
<div class="cl pd-20" style=" background-color:#5bacb6">
    <img class="avatar round size-XL l" src="<?php echo $info['portrait'] ?: '/static/admin/picture/avatar.png'?>" id="portrait">
    <dl class="f-12" style="margin-left:80px; color:#fff">
        <dt>
            <span class="f-18"><?php echo $info['username']?></span>
                <a href="javascript:;" title="修改密码" onclick="show('修改密码','<?php echo url('admin/setPassword',['id'=>$info['id']])?>','','400')"><i class="Hui-iconfont">&#xe63f;</i></a>
            <span class="ml-10">状态：<?php switch($info['status']){
                case 1: echo '已启用';break;
                case 2: echo '已禁用';break;
            }?></span>
            <span class="ml-10">用户组：<?php echo $info['group_name']?></span>
            <span class="btn-upload" style="height: 23px">
                <a class="ml-10" href="javascript:void();"><i class="Hui-iconfont">&#xe642;</i> 头像</a>
                <input id="file" type="file" name="image[]" class="input-file" onchange="ajaxFileUpload('<?php echo  url('admin/portraitUpload')?>','file','portrait')">
            </span>
            <?php if($info['pid'] == 0) {?>
            <a class="ml-10" href="javascript:;" title="添加下级用户组" onclick="show('添加用户组','<?php echo url('group/groupRelation',['id'=>$info['group_id']])?>')"><i class="Hui-iconfont f-14">&#xe611;</i> 添加组</a>
            <a class="ml-10" href="javascript:;" title="添加下级用户组管理员" onclick="show('添加管理员','<?php echo url('admin/adminSave',['source'=>'ucenter'])?>','','400')"><i class="Hui-iconfont f-16">&#xe607;</i> 添加用户</a>
            <?php }?>
        </dt>
        <dd class="pt-10" style="margin-left:0">
            <span>创建时间：<?php echo $info['create_time'] ? date('Y-m-d H:i:s',$info['create_time']) : '-'?></span>
            <span class="pl-10">更新时间：<?php echo $info['update_time'] ? date('Y-m-d H:i:s',$info['update_time']) : '-'?></span>
            <span class="pl-10">最后登录时间：<?php echo $info['last_login_time'] ? date('Y-m-d H:i:s',$info['last_login_time']) : '-'?></span>
            <span class="pl-10">最后登录IP：<?php echo long2ip($info['last_login_ip'])?></span>
        </dd>
    </dl>
</div>
<div class="page-container">
    <div id="tab-system" class="HuiTab">
        <div class="tabBar cl f-12" style="position: relative">
            <span onclick="clickTab(1)">操作日志</span>
            <?php if($info['pid'] == 0) {?>
            <span onclick="clickTab(2)">下级用户</span>
            <span onclick="clickTab(3)">下级用户组</span>
            <?php }?>
            <div class="r" style="position: absolute; right: 5px;bottom: 5px">共有记录：<strong><?php echo isset($list) ? $list->total() : 0;?></strong> 条</div>
        </div>
        <div class="tabCon">
            <table class="table table-border table-bordered table-hover table-bg table-sort mt-20">
                <thead>
                <tr class="text-c">
                    <th>日志内容</th>
                    <th width="80">客户端IP</th>
                    <th width="120">操作时间</th>
                </tr>
                </thead>
                <tbody>
                <?php if (!empty($list->items())) { foreach($list->items() as $v){?>
                <tr class="text-c">
                    <td><a title="详情" href="javascript:;" onclick="show('日志详情','<?php echo url('system/logShow',array('id' => $v['id']))?>','','500')">
                        <?php echo (mb_strlen($v['desc'],'utf-8') > 50 ? mb_substr($v['desc'],0,50).'...' : $v['desc'])?></a>
                    </td>
                    <td><?php echo long2ip($v['uip'])?></td>
                    <td><?php echo date('Y-m-d H:i:s',$v['create_time'])?></td>
                </tr>
                <?php } } else {?>
                <tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
                <?php }?>
                </tbody>
            </table>
            <span class="r pages mt-10"><?php echo !empty($list->items()) ? $list->render() : '';?></span>
        </div>

        <?php if($info['pid'] == 0) {?>
        <div class="tabCon">
            <table class="table table-border table-bordered table-hover table-bg table-sort mt-20">
                <thead>
                <tr class="text-c">
                    <th width="40">ID</th>
                    <th width="80">用户名</th>
                    <th>角色名称</th>
                    <th width="80">最后登录IP</th>
                    <th width="120">最后登录时间</th>
                    <th width="120">创建时间</th>
                    <th width="120">更新时间</th>
                    <th width="70">状态</th>
                    <th width="70">操作</th>
                </tr>
                </thead>
                <tbody>
                <?php if (!empty($admin)) { foreach($admin as $v){?>
                <tr class="text-c">
                    <td><?php echo $v['id']?></td>
                    <td><?php echo $v['username']?></td>
                    <td><?php echo $v['group_name']?></td>
                    <td><?php echo $v['last_login_ip'] ? long2ip($v['last_login_ip']) : '-'?></td>
                    <td><?php echo $v['last_login_time'] ? date('Y-m-d H:i:s',$v['last_login_time']) : '-'?></td>
                    <td><?php echo empty($v['create_time']) ? '-' : date('Y-m-d H:i:s',$v['create_time'])?></td>
                    <td><?php echo empty($v['update_time']) ? '-' : date('Y-m-d H:i:s',$v['update_time'])?></td>
                    <td class="td-status"><span class="label <?php echo $v['status'] == 1 ? 'label-success' : 'label-defaunt';?> radius">
                        <?php echo $v['status'] == 1 ? '已启用' : '已禁用';?></span>
                    </td>
                    <td class="td-manage">
                        <?php if($v['status'] == 1){?>
                        <a href="javascript:;" title="禁用" onclick="status(this,'<?php echo url('admin/status')?>','<?php echo $v['id']?>', 2, '禁用')"><i class="Hui-iconfont">&#xe60e;</i></a>
                        <?php } if($v['status'] == 2) {?>
                        <a href="javascript:;" title="启用" onclick="status(this,'<?php echo url('admin/status')?>','<?php echo $v['id']?>', 1, '启用')"><i class="Hui-iconfont">&#xe605;</i></a>
                        <?php }?>
                        <a class="ml-5" href="javascript:;" title="重置密码" onclick="resetPassword(this,'<?php echo url('admin/resetPassword')?>', '<?php echo $v['id']?>')"><i class="Hui-iconfont">&#xe63f;</i></a>
                        <a class="ml-5" href="javascript:;" title="编辑"  onclick="show('编辑用户','<?php echo url('admin/adminSave',['id'=>$v['id'],'source'=>'ucenter'])?>','','400')"><i class="Hui-iconfont">&#xe6df;</i></a>
                    </td>
                </tr>
                <?php } } else {?>
                <tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
                <?php }?>
                </tbody>
            </table>
        </div>

        <div class="tabCon">
            <table class="table table-border table-bordered table-hover table-bg table-sort mt-20">
                <thead>
                <tr class="text-c">
                    <th>权限</th>
                    <th width="100">用户组名称</th>
                    <th width="70">状态</th>
                    <th width="70">操作</th>
                </tr>
                </thead>
                <tbody>
                <?php if (!empty($group)) { foreach($group as $v){?>
                <tr class="text-c">
                    <td><?php echo $v['auth_ids']?></td>
                    <td><?php echo $v['group_name']?></td>
                    <td class="td-status"><span class="label <?php echo $v['status'] == 1 ? 'label-success' : 'label-defaunt';?> radius">
                        <?php echo $v['status'] == 1 ? '已启用' : '已禁用';?></span>
                    </td>
                    <td class="td-manage">
                        <?php if($v['status'] == 1){?>
                        <a href="javascript:;" title="禁用" onclick="status(this,'<?php echo url('group/status')?>','<?php echo $v['id']?>', 2, '禁用')"><i class="Hui-iconfont">&#xe60e;</i></a>
                        <?php } if($v['status'] == 2) {?>
                        <a href="javascript:;" title="启用" onclick="status(this,'<?php echo url('group/status')?>','<?php echo $v['id']?>', 1, '启用')"><i class="Hui-iconfont">&#xe605;</i></a>
                        <?php }?>
                        <a class="ml-5" href="javascript:;" title="编辑"  onclick="show('用户组编辑','<?php echo url('group/groupSave',['id'=>$v['id']])?>')"><i class="Hui-iconfont">&#xe6df;</i></a>
                    </td>
                </tr>
                <?php } } else {?>
                <tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
                <?php }?>
                </tbody>
            </table>
        </div>
        <?php }?>
    </div>
</div>
{/block}
<!--请在上方方写此页面body相关内容-->
<!--请在下方写此页面业务相关的脚本-->
{block name="js"}
<script type="text/javascript">
$(function () {
    $('img').zoomify();
    $("#tab-system").Huitab({ tabBar:".tabBar span", tabCon: ".tabCon", className: "current", tabEvent: "click", index: "0" });
});

function clickTab(tab) {
    var count = 0;
    if(tab === 1){
        count = "<?php echo !empty($list) ? $list->total() : 0;?>";
    } else if (tab === 2) {
        count = "<?php echo !empty($info['count_admin']) ? $info['count_admin'] : 0;?>";
    } else if (tab === 3) {
        count = "<?php echo !empty($info['count_group']) ? $info['count_group'] : 0;?>";
    }
    $('.tabBar div strong').html(count)
}
</script>
{/block}
<!--/请在上方写此页面业务相关的脚本-->